/*
 *  Copyright 2001-2004 The Apache Software Foundation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package ar.uba.fi.posgrado.academy.web.form.subject;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.LabelValueBean;

import ar.uba.fi.posgrado.academy.model.AcademicRecord;
import ar.uba.fi.posgrado.academy.model.Coursing;
import ar.uba.fi.posgrado.academy.model.Subject;

/**
 * Form para {@link Subject}
 * 
 * @author ariel.piechotka
 */
@SuppressWarnings("serial")
public class AcademicRecordForm extends ActionForm {

	private Long id;

	private List<LabelValueBean> subjectOptions = new ArrayList<LabelValueBean>();

	private Long idSubject;

	private List<LabelValueBean> teacherOptions = new ArrayList<LabelValueBean>();

	private Long teacherId;

	private String date;

	private Short qtyStudents;

	private String[] studentsIds;

	private String studentMark;

	// Para el autocomplete
	private Long studentId;

	private String studentSurname;

	private String teacherName;
	
	private List<AcademicRecord> academicRecords = new ArrayList<AcademicRecord>();

	private Set<Coursing> coursings = new HashSet<Coursing>();

	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrors actionErrors = new ActionErrors();

		return actionErrors;
	}

	public void clear() {
		id = null;
		idSubject = null;
		teacherId = null;
		date = "";
		setQtyStudents(AcademicRecord.DEFAULT_QTY_STUDENTS);
		studentId = null;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getIdSubject() {
		return idSubject;
	}

	public void setIdSubject(Long idSubject) {
		this.idSubject = idSubject;
	}

	public Long getTeacherId() {
		return teacherId;
	}

	public void setTeacherId(Long idTeacher) {
		this.teacherId = idTeacher;
	}

	public Short getQtyStudents() {
		return qtyStudents;
	}

	public void setQtyStudents(Short qtyStudents) {
		this.qtyStudents = qtyStudents;
		studentsIds = new String[qtyStudents];
		for (int i = 0; i < qtyStudents; i++)
			studentsIds[i] = "";
	}

	public Long getStudentId() {
		return studentId;
	}

	public void setStudentId(Long studentId) {
		this.studentId = studentId;
	}

	public String[] getStudentsIds() {
		return studentsIds;
	}

	public void setStudentsIds(String[] studentsIds) {
		this.studentsIds = studentsIds;
	}

	public String getStudentSurname() {
		return studentSurname;
	}

	public void setStudentSurname(String studentSurname) {
		this.studentSurname = studentSurname;
	}

	public List<LabelValueBean> getSubjectOptions() {
		return subjectOptions;
	}

	public void setSubjectOptions(List<LabelValueBean> subjectOptions) {
		this.subjectOptions = subjectOptions;
	}

	public List<LabelValueBean> getTeacherOptions() {
		return teacherOptions;
	}

	public void setTeacherOptions(List<LabelValueBean> teacherOptions) {
		this.teacherOptions = teacherOptions;
	}

	public List<LabelValueBean> getQtyStudentsOptions() {
		List<LabelValueBean> result = new ArrayList<LabelValueBean>();
		for (Integer i = 1; i <= AcademicRecord.MAX_QTY_STUDENTS; i++)
			result.add(new LabelValueBean(i.toString(), i.toString()));
		return result;
	}

	public String getTeacherName() {
		return teacherName;
	}

	public void setTeacherName(String teacherName) {
		this.teacherName = teacherName;
	}

	public String getStudentMark() {
		return studentMark;
	}

	public void setStudentMark(String studentMark) {
		this.studentMark = studentMark;
	}

	public List<AcademicRecord> getAcademicRecords() {
		return academicRecords;
	}

	public void setAcademicRecords(List<AcademicRecord> academicRecords) {
		this.academicRecords = academicRecords;
	}

	public Set<Coursing> getCoursings() {
		return coursings;
	}

	public void setCoursings(Set<Coursing> coursings) {
		this.coursings = coursings;
	}
}
